<template>
	<el-card style="margin-left: 35%;margin-top: 12.5rem;">
		
	<el-main>
		<h2 style="text-align: center;">修改密码</h2>
		旧密码：<el-input  v-model="data.gopwd" type="password" placeholder="旧密码" style="width: 250px;margin-left: 4rem;"></el-input><br><br>
		新密码：<el-input v-model="data.dopwd" type="password" placeholder="新密码" style="width: 250px;margin-left: 4rem;" show-password>
		</el-input><br><br>
		再次输入新密码：<el-input v-model="data.dopwd2" type="password" placeholder="再次输入新密码" show-password
			style="width: 250px;"></el-input><br><br>
		<el-button style="margin-left: 35%; background-color: #E1337F;color: aliceblue;"  @click="updated()">
			<el-icon>
				<Pointer />
			</el-icon>确认修改
		</el-button>
	</el-main>
	
	</el-card>
</template>

<script setup>
	import {
		ref,
		reactive,
		onMounted,
		computed
	} from "vue"
	import {
		$get,
		$postx,
		$postj,
		$postf
	} from '../ajax/index.js'
	import {
		Delete,
		EditPen,
		Loading,
		Plus
	} from '@element-plus/icons-vue'
	import {
		success,
		warning,
		message,
		errors
	} from '../store/alert.js'
	import {Search,ShoppingCart,Pointer} from '@element-plus/icons-vue'
	const data = reactive({
		gopwd: "",
		dopwd: "",
		dopwd2: ""
	})
	
	function updated() {
		if (data.dopwd != data.dopwd2) {
			warning("新密码不一致")
			return
		}
		if (data.dopwd == "" || data.gopwd == "") {
			errors("密码不允许为空")
			return
		}
		let a = {
			oldpwd: data.gopwd,
			newpwd: data.dopwd
		}
		$postx("/user/updatapwd", a).then((read) => {
			if(read.data.code==401){
				errors(read.data.msg)
			}else{
				success(read.data.msg)
			}
			
		})
	}
	
</script>

<style>
</style>